<?php

class posModel extends commonModel {
    public function __construct() {
        $this->initialDB();
    }


    /** 修改订单信息
     * @param $data
     */
    public function EditOrder($data){
        $where = array("AND" => array("=" => array('order_no' => $data['order_no'], 'isdeleted' => 0)));
        $result = $this->getItemByOther($where, "orders");
        $res = [];
        if(!$result){
            $res['result']['status'] = 1;
            $res['result']['msg'] = '订单不存在';
            return $res;exit;
        }elseif ($result[0]['pos_no']){
            $res['result']['status'] = 1;
            $res['result']['msg'] = '订单pos单号已存在';
            return $res; exit;
        }

        $field = array();
        $field['pos_no'] = $data['pos_no'];
        $field['updatedt'] = 'now()';
        $r = $this->updateItem($field, $where, 'orders');
        if (!$r) {
            $res['result']['status'] = '-1';
            $res['result']['msg'] = '系统繁忙';
        }
        return $res;
    }
}